package com.example.www;

import gnu.io.NRSerialPort;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Test {

    public static void main(String[] args) {
        for(String s:NRSerialPort.getAvailableSerialPorts()){
            System.out.println("Availible port: "+s);
        }
        String port = "COM6";
        int baudRate = 9600;
        NRSerialPort serial = new NRSerialPort(port, baudRate);
        serial.connect();
        DataInputStream ins = new DataInputStream(serial.getInputStream());
        DataOutputStream outs = new DataOutputStream(serial.getOutputStream());
        byte b = 0;
        while (true) {
            try {
                b = (byte) ins.read();
//                System.out.println(b);
                if(b!=-1)outs.write(b);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

